package ZC;

import java.awt.Dimension;
import java.awt.Font;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.WindowConstants;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.JTableHeader;
public class AllInventory extends JFrame {
	private JPanel main_pl;//
	private JLabel top_lb;//某某影院欢迎你的顶部标签
	private JLabel my_lb;//我的订单的标签
	private JLabel bg_lb;//背景图片标签
	private JButton back_bt;//返回上一页的按钮
	private JButton leave_bt;//退出的按钮
	private String [] mvColumnNames = {"电影名","场次","已售票数","剩余可售票数"};
	private JScrollPane mv_sp;//我的电影的滚打面板
	private JTable my_tb;//我的订单的表格
	private ImageIcon bg_image;//背景图片
	public AllInventory() {
		/* 设置面板的背景 
		 * 首先创建两个面板
		 *一个面板添加你所要放的背景图并设置为透明
		 *再把组件加到另一个面板中去
		 *最后有组件的面板添加到有背景图片的面板
		 * 
        */
        //背景图片存放的标签以及面板
		bg_image = new ImageIcon("背景.jpeg");
		bg_lb = new JLabel(bg_image);
		bg_lb.setBounds(0, 0, bg_image.getIconWidth(), bg_image.getIconHeight());//大小由图片的大小决定
		JPanel biggest_panel = new JPanel();
		biggest_panel.setLayout(null);//绝对布局
		//存放组件的面板
		main_pl = new JPanel();
		main_pl.setLayout(null);
		main_pl.setOpaque(false);//设置主面板为透明
		main_pl.setBounds(0, 0, 1500, 800);
		my_lb = new JLabel("售票情况如下：");
		my_lb.setFont(new Font("楷体",Font.PLAIN,20));
		my_lb.setBounds(610, 90, 160, 40);
		main_pl.add(my_lb);
		//按钮块
		back_bt = new JButton("返回上一页");
		back_bt.setFont(new Font("楷体",Font.PLAIN,20));
		back_bt.setBounds(300, 500, 150, 40);
		main_pl.add(back_bt);
		leave_bt = new JButton("退出");
		leave_bt.setFont(new Font("楷体",Font.PLAIN,20));
		leave_bt.setBounds(900, 500, 150, 40);
		main_pl.add(leave_bt);
		mv_sp = new JScrollPane();//添加滚动面板
		mv_sp.setBounds(300,160,750,300);
		main_pl.add(mv_sp);
		my_tb= new JTable();
		DefaultTableCellRenderer r = new DefaultTableCellRenderer();
		r.setHorizontalAlignment(JLabel.CENTER);//设置表格内容居中
		my_tb.setDefaultRenderer(Object.class,r);
		my_tb.setRowHeight(38);//设置行高
		my_tb.setShowGrid(true);//设置边框显示出来
		JTableHeader head = my_tb.getTableHeader();//设置表格标题对象
		head.setPreferredSize(new Dimension(head.getWidth(),35));//設置表頭大小
		head.setFont(new Font("楷体",Font.PLAIN,20));//设置表头字体
		my_tb.setFont(new Font("宋体",Font.PLAIN,20));//设置表格字体
		mv_sp.setViewportView(my_tb);//添加到滚动面板
		String [][] data = new String[7][];
		my_tb.setModel(new DefaultTableModel(data,mvColumnNames));
		biggest_panel.add(main_pl);
		this.getLayeredPane().setLayout(null);
		this.getLayeredPane().add(bg_lb, new Integer(Integer.MIN_VALUE));
		this.setContentPane(biggest_panel);
		setTitle("某某电影");//标题
		setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);//窗口关闭方式
		setSize(1500, 800);//尺寸
		setLocationRelativeTo(null);//居中
		setVisible(true);//可见
	}
	public static void main(String[] args) {
		new AllInventory();
	}
}
